import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:xinxuan/utils/color_util.dart';

class SortItem extends StatelessWidget {

  final String title;
  final int index;
  final bool showBorder;
  final Function onTap;
  final bool isPriceSort;
  
  SortItem({
    required this.title,
    required this.index,
    required this.showBorder,
    required this.onTap,
    this.isPriceSort = false
  });

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        InkWellUtil.shakeProofInkWell(Container(
          width: 125.w,
          height: 45.h,
          alignment: Alignment.center,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                title,
                style: TextStyle(
                  color: showBorder ? mainTextColor : textBlackColor,
                  fontSize: showBorder ? 18.sp : 16.sp
                ),
              ),
              isPriceSort ? _sortIcon() : Container()
            ],
          ),
        ), () => onTap()),
        Positioned(
          bottom: 7.h,
          left: 53.w,
          child: showBorder ? Container(
            width: 20.w,
            height: 3.h,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(5.w),
              color: bgMainColor
            ),
          ) : Container()
        )
      ],
    );
  }

  Widget _sortIcon() {
    return Row(
      children: [
        SizedBox(width: 2.w),
        Image.asset(
          'assets/icons/icon_sort.png',
          width: 10.w,
          height: 12.h,
        )
      ],
    );
  }
}